home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / clipfp.zip / CLFPCX87.PRG < prev    next >
Text File  |  1991-05-24  |  3KB  |  96 lines

  1. * ------------------------------------------------------------------------
  2. * Module.......: CLPFPCX87.PRG
  3. * Author.......: Pepijn Smits.
  4. * Date.........: Mar 1991
  5. * Copyright....: (c)1991, Pepijn Smits Software.
  6. * Notes........: Clipper '87 part of Clipper "Fast" EGA/VGA PCX library.
  7. * ------------------------------------------------------------------------
  8. * FastPCX():    Display a EGA/VGA PCX picture on the screen, quickly..
  9. * returns:    0 = All okay, still in Graph mode, restore with txtMode()!
  10. *        1 - file not found
  11. *        2 - not PCX file!
  12. *        3 - Not proper format (not full screen EGA/VGA PCX file)
  13. * Assumes VGA or EGA installed when PCX file requires one.
  14. * [But that could of Course be checked using Expand's EGAthere()/VGAthere()]
  15.  
  16. Function FastPCX
  17. Parameter Filename
  18. Private Handle
  19. Private Header
  20. Private BPP,X2,Y2            && Bits/Pixel, Lower X and Y
  21. Private Count
  22. Private Palette
  23. Private Buffer
  24. handle = fopen(filename)
  25. if Handle <= 0
  26.     return 1            && Open Error        
  27. else
  28.     Header = Space(128)
  29.     fread(handle,@header,128)
  30.     if SubStr(Header,1,1) <> chr(10)
  31.         fclose(handle)
  32.         return 2        && Not PCX file!
  33.     else
  34.         * - Determine if format Okay, ie. if PCX is:
  35.         * - VGA 320x200x256 or VGA 640x480x16 or EGA 640x350x16
  36.         BPP = Asc(SubStr(Header,4,1))
  37.         X2 = Bin2w(SubStr(Header,9,2))
  38.         Y2 = Bin2w(SubStr(Header,11,2))
  39.  
  40.         if (BPP=8) .and. (X2=319) .and. (Y2=199)
  41.             * - Got a VGA 320x200x256 here..
  42.  
  43.             * - Read the Palette Info
  44.             Palette = Space(768)
  45.             fseek(handle,-768,2)
  46.             fread(handle,@palette,768)
  47.  
  48.             * - Determine length and goto begin picture
  49.             Count = fseek(handle,0,2) - 128 - 768
  50.             buffer = Space(Count)
  51.             fseek(handle,128)
  52.  
  53.             * - Set VGA mode, Palette and Draw the picture.
  54.             VGA13mode()
  55.             SetVGAPal(@Palette,256)
  56.             fread(handle,@buffer,Count)
  57.             VGA13Show(@Buffer,Count)
  58.  
  59.         elseif (BPP=1) .and. (X2=639) .and. (Y2=479)
  60.             * - Got a VGA 640x480x16 here..
  61.  
  62.             * - Determine length, and goto begin picture
  63.             Count = fseek(handle,0,2) - 128
  64.             buffer = space(Count)
  65.             fseek(handle,128)
  66.  
  67.             * - Set VGA mode, Palette and Draw the picture.
  68.             VGA12init()
  69.             SetVGAPal(SubStr(Header,17,48),16)
  70.             fread(handle,@buffer,Count)
  71.             VGA12Show(@Buffer,Count)
  72.  
  73.         elseif (BPP=1) .and. (X2=639) .and. (Y2=349) 
  74.             * - Got a EGA 640x350x16 here..
  75.  
  76.             * - Determine length, and goto begin picture
  77.             Count = fseek(handle,0,2) - 128
  78.             buffer = space(Count)
  79.             fseek(handle,128)
  80.  
  81.             * - Set EGA mode, Palette and Draw the picture
  82.             EGA10init()
  83.             SetEGApal(SubStr(Header,17,48))
  84.             fread(handle,@buffer,Count)
  85.             EGA10Show(@Buffer,Count)
  86.  
  87.         else
  88.             * - Nope, no supported picture here...
  89.             fclose(handle)
  90.             return 3
  91.         endif
  92.         fclose(handle)
  93.         return 0
  94.     endif
  95. endif
  96.